FROM nginx:1.16-alpine

ARG X_GID
ARG X_UID
ARG BASE_DOMAIN

RUN set -eux; \
    if [ -z "`getent group ${X_GID}`" ]; then \
        addgroup --system --gid ${X_GID} clonetrooper; \
    fi; \
    adduser --system --disabled-password -S --uid ${X_UID} -G clonetrooper clonetrooper 

COPY ./conf.d/ /etc/nginx/conf.d/
COPY ./nginx.conf /etc/nginx/nginx.conf
COPY  --from=php-yjs-pay:latest  /data/www/pay/ /data/www/pay/

RUN envsubst '${BASE_DOMAIN}' < /etc/nginx/conf.d/site.conf.template > /etc/nginx/conf.d/site.conf

WORKDIR /data/www/pay

EXPOSE 80
